﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DevExpress.Xpo;
using Component;

public partial class FrontEnd_Body_Center_Product : System.Web.UI.UserControl
{
    public XPCollection<Product> _xpProduct = new XPCollection<Product>(Component.KetNoiCSDL.session);
    public ArrayList _products = new ArrayList();
    protected string _paggingCollection;
    public string _Path="";
    public string _Contact = ConstString._Default + ConstString._Contact+"&"+ConstString._LienHeGia+"="+ConstString._LienHeGia;
    protected void Page_Load(object sender, EventArgs e)
    {
        
        _xpProduct = null;
        XPCollection<CategorySub> _cpCatSub = new XPCollection<CategorySub>(KetNoiCSDL.session);
        //int idCat = ConvertType.ToInt(QueryHelper.GetQueryString(Request, ConstString._idcat));
        int idCatSub = ConvertType.ToInt(QueryHelper.GetQueryString(Request, ConstString._idsubcat));
        //if (idCat > 0)
        //{
        //    _xpProduct = ProductDB.GetAllObjByIdCat(idCat, false);
        //}

        //else
        //{

            if (idCatSub > 0)
            {
                _xpProduct = ProductDB.GetAllObjByIdCatSub(idCatSub, false);
                CategorySub cateSub = new CategorySub(KetNoiCSDL.session);
                cateSub =CategorySubDB.GetObjectByid(idCatSub,false);
                _Path=Languages.GetContentByLanguage(cateSub.Category.Name,cateSub.Category.NameEL) +">>"+Languages.GetContentByLanguage(cateSub.Name,cateSub.NameEL);
            }
            else
            {
                _Path = Component.Languages.SearchByKeyWord("spm2");
                _xpProduct = ProductDB.GetAll(false);
            }
        //}
        ArrayList al = new ArrayList();
        if (_xpProduct.Count > 0)
            al.AddRange(_xpProduct.ToArray());
        _products = Pager.ShowInfomationPaging(idCatSub.ToString(), ConstString._AjaxProduct, 8, 3, al, ref _paggingCollection);
    }
}
